<template>
    <div>
        <el-pagination
            :current-page.sync="currentPage"
            @current-change="handleCurrentChange"
            :page-size="5"
            layout="total, prev, pager, next"
            :total="num">
        </el-pagination>
    </div>
</template>

<script>
export default {
    data() {
        return {
            currentPage: 1,
        };
    },
    created(){
        this.currentPage = JSON.parse(sessionStorage.getItem('currentPage')) || 1
    },
    methods: {
        handleCurrentChange(val) {
            this.currentPage = val
            sessionStorage.setItem('currentPage', JSON.stringify(val))
            this.$router.push({
                path: name,
                query:  { page: this.currentPage }
            })      
        }
    },
    props:['num', 'name']
};
</script>

<style scoped lang="scss">

</style>
